﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Runtime.InteropServices;

    public class MoneyChangeLog
    {
        private readonly Chain.IDAL.MoneyChangeLog dal = new Chain.IDAL.MoneyChangeLog();

        public int Add(Chain.Model.MoneyChangeLog model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.MoneyChangeLog> DataTableToList(DataTable dt)
        {
            List<Chain.Model.MoneyChangeLog> list = new List<Chain.Model.MoneyChangeLog>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.MoneyChangeLog item = new Chain.Model.MoneyChangeLog();
                    if ((dt.Rows[i]["MoneyChangeID"] != null) && (dt.Rows[i]["MoneyChangeID"].ToString() != ""))
                    {
                        item.MoneyChangeID = int.Parse(dt.Rows[i]["MoneyChangeID"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeMemID"] != null) && (dt.Rows[i]["MoneyChangeMemID"].ToString() != ""))
                    {
                        item.MoneyChangeMemID = int.Parse(dt.Rows[i]["MoneyChangeMemID"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeUserID"] != null) && (dt.Rows[i]["MoneyChangeUserID"].ToString() != ""))
                    {
                        item.MoneyChangeUserID = int.Parse(dt.Rows[i]["MoneyChangeUserID"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeType"] != null) && (dt.Rows[i]["MoneyChangeType"].ToString() != ""))
                    {
                        item.MoneyChangeType = int.Parse(dt.Rows[i]["MoneyChangeType"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeAccount"] != null) && (dt.Rows[i]["MoneyChangeAccount"].ToString() != ""))
                    {
                        item.MoneyChangeAccount = dt.Rows[i]["MoneyChangeAccount"].ToString();
                    }
                    if ((dt.Rows[i]["MoneyChangeMoney"] != null) && (dt.Rows[i]["MoneyChangeMoney"].ToString() != ""))
                    {
                        item.MoneyChangeMoney = decimal.Parse(dt.Rows[i]["MoneyChangeMoney"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeCash"] != null) && (dt.Rows[i]["MoneyChangeCash"].ToString() != ""))
                    {
                        item.MoneyChangeCash = decimal.Parse(dt.Rows[i]["MoneyChangeCash"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeBalance"] != null) && (dt.Rows[i]["MoneyChangeBalance"].ToString() != ""))
                    {
                        item.MoneyChangeBalance = decimal.Parse(dt.Rows[i]["MoneyChangeBalance"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeUnionPay"] != null) && (dt.Rows[i]["MoneyChangeUnionPay"].ToString() != ""))
                    {
                        item.MoneyChangeUnionPay = decimal.Parse(dt.Rows[i]["MoneyChangeUnionPay"].ToString());
                    }
                    if ((dt.Rows[i]["MemMoney"] != null) && (dt.Rows[i]["MemMoney"].ToString() != ""))
                    {
                        item.MemMoney = decimal.Parse(dt.Rows[i]["MemMoney"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeCreateTime"] != null) && (dt.Rows[i]["MoneyChangeCreateTime"].ToString() != ""))
                    {
                        item.MoneyChangeCreateTime = DateTime.Parse(dt.Rows[i]["MoneyChangeCreateTime"].ToString());
                    }
                    if ((dt.Rows[i]["MoneyChangeGiveMoney"] != null) && (dt.Rows[i]["MoneyChangeGiveMoney"].ToString() != ""))
                    {
                        item.MoneyChangeGiveMoney = decimal.Parse(dt.Rows[i]["MoneyChangeGiveMoney"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int MoneyChangeID)
        {
            return this.dal.Delete(MoneyChangeID);
        }

        public bool DeleteList(string MoneyChangeIDlist)
        {
            return this.dal.DeleteList(MoneyChangeIDlist);
        }

        public bool Exists(int MoneyChangeID)
        {
            return this.dal.Exists(MoneyChangeID);
        }

        public bool Exists(string orderaccount)
        {
            return this.dal.Exists(orderaccount);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public Chain.Model.MoneyChangeLog GetModel(int MoneyChangeID)
        {
            return this.dal.GetModel(MoneyChangeID);
        }

        public List<Chain.Model.MoneyChangeLog> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public DataSet GetMoneyChange(string strSql)
        {
            return this.dal.GetMoneyChange(strSql);
        }

        public DataSet GetMoneyChangeLog(int PageSize, int PageIndex, out int resCount, params string[] strWhere)
        {
            return this.dal.GetMoneyChangeLog(PageSize, PageIndex, out resCount, strWhere);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public bool Update(Chain.Model.MoneyChangeLog model)
        {
            return this.dal.Update(model);
        }
    }
}

